﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Otgruzka.ServicesClients;
using BusinessLogic.Security;
using Otgruzka.Helpers;
using System.ServiceModel;

namespace Otgruzka.WebForms
{
    public partial class ExpendBillDetailsPrint : System.Web.UI.Page
    {
        protected string tableExpendBill = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["oid"] != null && Request.QueryString["exbid"] != null)
            {
                var client = new ExpendBillsClient();
                try
                {
                    int ExpendBillId = Convert.ToInt16(Request.QueryString["exbid"]);
                    var expendBill = client.GetExpendBill(UserPrincipal.Current.UserId, ExpendBillId);  // Получение объекта Расходная накладная из базы данных
                    tableExpendBill = ObjectToHtmlHelper.GetExpedBillHTML(expendBill);
                }
                catch (System.ServiceModel.FaultException<ExceptionDetail> ex)
                {
                    string message = client.GetExceptionDetail(ex);
                    this.ErrorMessage.Text = message;
                }
                catch (System.Exception exp)
                {
                    this.ErrorMessage.Text = exp.Message;
                }
            }
        }
    }
}